package com.xingdata.jjxc.adapter;

import java.util.List;

import com.xingdata.jjxc.R;
import com.xingdata.jjxc.activity.CarTypeActivity;
import com.xingdata.jjxc.enty.AddCarEntity;
import com.xingdata.jjxc.enty.CarBrandEntity;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class CarTypeListAdapter extends BaseAdapter {
	private List<AddCarEntity> addCarEntities;
	private Context context;

	public CarTypeListAdapter(CarTypeActivity carTypeActivity,
			List<AddCarEntity> addCarEntities) {
		this.addCarEntities = addCarEntities;
		this.context = carTypeActivity;
	}

	@Override
	public int getCount() {
		return addCarEntities == null ? 0 : addCarEntities.size();
	}

	@Override
	public Object getItem(int position) {
		return addCarEntities.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Holder holder = null;
		if (convertView == null) {
			holder = new Holder();
			convertView = LayoutInflater.from(context).inflate(
					R.layout.cartypelist_item, null);
			holder.addcartypelist = (TextView) convertView
					.findViewById(R.id.cartype_tv);
//			holder.addcartypelist.setOnClickListener(new OnClickListener() {
//				
//				@Override
//				public void onClick(View v) {
//					
//				}
//			});
			convertView.setTag(holder);
		} else {
			holder = (Holder) convertView.getTag();
		}

//		for (int i = 0; i < addCarEntities.get(position).getCarModeLlists()
//				.size(); i++) {
//			
//		}
		holder.addcartypelist.setText(addCarEntities.get(position).getCar_model_name());
		return convertView;
	}

	final class Holder {
		TextView addcartypelist;
	}
}
